home *** CD-ROM | disk | FTP | other *** search
-
-
-
- RRRRWWWWGGGGBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++)))) RRRRWWWWGGGGBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++))))
-
-
-
- NNNNaaaammmmeeee
- RWGBitVec(size) - Rogue Wave library class
-
- SSSSyyyynnnnooooppppssssiiiissss
- #include <rw/gbitvec.h>
-
-
-
- declare(RWGBitVec,ssssiiiizzzzeeee)
- RWGBitVec(size) a;
-
-
-
-
- DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
- RRRRWWWWGGGGBBBBiiiittttVVVVeeeecccc((((ssssiiiizzzzeeee)))) is a bit vector of fixed length ssssiiiizzzzeeee. The length cannot
- be changed dynamically (see class RRRRWWWWBBBBiiiittttVVVVeeeecccc if you need a bit vector whose
- length can be changed at run time). Objects of type RRRRWWWWGGGGBBBBiiiittttVVVVeeeecccc((((ssssiiiizzzzeeee)))) are
- declared with macros defined in the standard C++ header file <<<<ggggeeeennnneeeerrrriiiicccc....hhhh>>>>.
- Bits are numbered from 0 through ssssiiiizzzzeeee----1111, inclusive.
-
- PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
- None
-
- EEEExxxxaaaammmmpppplllleeee
- In this example, a bit vector 24 bits long is declared and exercised:
-
- #include "rw/gbitvec.h"
- #include <iostream.h>
- const int VECSIZE = 8;
- declare(RWGBitVec, VECSIZE) // declare a 24 bit long vector
- implement(RWGBitVec, VECSIZE) // implement the vector
- main()
- {
- RWGBitVec(VECSIZE) a, b; // Allocate two vectors.
- a(2) = TRUE; // Set bit 2 (the third bit) of a on.
- b(3) = TRUE; // Set bit 3 (the fourth bit) of b on.
- RWGBitVec(VECSIZE) c = a ^ b; // Set c to the XOR of a and b.
- cout << "Vector 1" << "" << "Vector 2" << ""
- << "Vector 1 xor Vector 2" << endl;
- for(int i = 0; i < VECSIZE; i++)
- cout << a[i] << "" << b[i] << "" << c[i] << endl;
- return 0;
- }
-
- PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
- RRRRWWWWGGGGBBBBiiiittttVVVVeeeecccc(ssssiiiizzzzeeee)();
-
-
- Construct a bit vector ssssiiiizzzzeeee elements long, with all bits initialized to
- FFFFAAAALLLLSSSSEEEE.
-
-
-
-
- PPPPaaaaggggeeee 1111
-
-
-
-
-
-
- RRRRWWWWGGGGBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++)))) RRRRWWWWGGGGBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++))))
-
-
-
- RRRRWWWWGGGGBBBBiiiittttVVVVeeeecccc(ssssiiiizzzzeeee)(RWBoolean f);
-
-
- Construct a bit vector ssssiiiizzzzeeee elements long, with all bits initialized to
- ffff.
-
- AAAAssssssssiiiiggggnnnnmmmmeeeennnntttt OOOOppppeeeerrrraaaattttoooorrrrssss
- RWGBitVec(sz)&
- ooooppppeeeerrrraaaattttoooorrrr====(const RWGBitVec(sz)& v);
-
-
- Set each element of self to the corresponding bit value of vvvv. Return a
- reference to self.
-
- RWGBitVec(sz)&
- ooooppppeeeerrrraaaattttoooorrrr====(RWBoolean f);
-
-
- Set all elements of self to the boolean value ffff.
-
- RWGBitVec(sz)&
- ooooppppeeeerrrraaaattttoooorrrr&&&&====(const RWGBitVec(sz)& v);
- RWGBitVec(sz)&
- ooooppppeeeerrrraaaattttoooorrrr^^^^====(const RWGBitVec(sz)& v);
- RWGBitVec(sz)&
- ooooppppeeeerrrraaaattttoooorrrr||||====(const RWGBitVec(sz)& v);
-
-
- Logical assignments. Set each element of self to the logical AAAANNNNDDDD, XXXXOOOORRRR,
- or OOOORRRR, respectively, of self and the corresponding bit in vvvv.
-
- IIIInnnnddddeeeexxxxiiiinnnngggg OOOOppppeeeerrrraaaattttoooorrrrssss
- RWBitRef
- ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](size_t i);
-
-
- Returns a reference to the iiiith bit of self. This reference can be used
- as an lvalue. The index iiii must be between 0000 and ssssiiiizzzzeeee----1111, inclusive.
- Bounds checking will occur.
-
- RWBitRef
- ooooppppeeeerrrraaaattttoooorrrr(((())))(size_t i);
-
-
- Returns a reference to the iiiith bit of self. This reference can be used
- as an lvalue. The index iiii must be between 0000 and ssssiiiizzzzeeee----1111, inclusive. No
- bounds checking is done.
-
- PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
- void
- cccclllleeeeaaaarrrrBBBBiiiitttt(size_t i);
-
-
-
-
- PPPPaaaaggggeeee 2222
-
-
-
-
-
-
- RRRRWWWWGGGGBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++)))) RRRRWWWWGGGGBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++))))
-
-
-
- Clears (i.e., sets to FFFFAAAALLLLSSSSEEEE) the bit with index iiii. The index iiii must be
- between 0 and ssssiiiizzzzeeee----1111. No bounds checking is performed. The following
- are equivalent, although cccclllleeeeaaaarrrrBBBBiiiitttt((((ssssiiiizzzzeeee____tttt)))) is slightly smaller and faster
- than using ooooppppeeeerrrraaaattttoooorrrr(((())))((((ssssiiiizzzzeeee____tttt)))):
-
- a(i) = FALSE;
-
-
-
- a.clearBit(i);
-
-
-
-
- const RWByte*
- ddddaaaattttaaaa() const;
-
-
- Returns a const pointer to the raw data of self. Should be used with
- care.
-
- void
- sssseeeettttBBBBiiiitttt(size_t i);
-
-
- Sets (iiii....eeee...., sets to TTTTRRRRUUUUEEEE) the bit with index iiii. The index iiii must be
- between 0 and ssssiiiizzzzeeee----1111. No bounds checking is performed. The following
- are equivalent, although sssseeeettttBBBBiiiitttt((((ssssiiiizzzzeeee____tttt)))) is slightly smaller and faster
- than using ooooppppeeeerrrraaaattttoooorrrr(((())))((((ssssiiiizzzzeeee____tttt))))::::
-
- a(i) = TRUE;
-
-
-
- a.setBit(i);
-
-
-
-
- RWBoolean
- tttteeeessssttttBBBBiiiitttt(size_t i) const;
-
-
- Tests the bit with index iiii. The index iiii must be between 0 and ssssiiiizzzzeeee----1111.
- No bounds checking is performed. The following are equivalent, although
- tttteeeessssttttBBBBiiiitttt((((ssssiiiizzzzeeee____tttt)))) is slightly smaller and faster than using
- ooooppppeeeerrrraaaattttoooorrrr(((())))((((ssssiiiizzzzeeee____tttt)))):
-
- if( a(i) ) doSomething();
-
-
-
-
-
-
- PPPPaaaaggggeeee 3333
-
-
-
-
-
-
- RRRRWWWWGGGGBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++)))) RRRRWWWWGGGGBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++))))
-
-
-
- if( a.testBit(i) ) doSomething();
-
-
-
- RRRReeeellllaaaatttteeeedddd GGGGlllloooobbbbaaaallll FFFFuuuunnnnccccttttiiiioooonnnnssss
- RWGBitVec(sz)
- ooooppppeeeerrrraaaattttoooorrrr&&&&(const RWGBitVec(sz)& v1, const RWGBitVec(sz)& v2);
- RWGBitVec(sz)
- ooooppppeeeerrrraaaattttoooorrrr^^^^(const RWGBitVec(sz)& v1, const RWGBitVec(sz)& v2);
- RWGBitVec(sz)
- ooooppppeeeerrrraaaattttoooorrrr||||(const RWGBitVec(sz)& v1, const RWGBitVec(sz)& v2);
-
-
- Return the logical AAAANNNNDDDD, XXXXOOOORRRR, and OOOORRRR, respectively, of vectors vvvv1111 and vvvv2222.
-
- RWBoolean
- ooooppppeeeerrrraaaattttoooorrrr========(const RWGBitVec(sz)& v1, const RWGBitVec(sz)& v2)
- const;
-
-
- Returns TTTTRRRRUUUUEEEE if each bit of vvvv1111 is set to the same value as the
- corresponding bit in vvvv2222. Otherwise, returns FFFFAAAALLLLSSSSEEEE.
-
- RWBoolean
- ooooppppeeeerrrraaaattttoooorrrr!!!!====(const RWGBitVec(sz)& v1, const RWGBitVec(sz)& v2)
- const;
-
-
- Returns FFFFAAAALLLLSSSSEEEE if each bit of vvvv1111 is set to the same value as the
- corresponding bit in vvvv2222. Otherwise, returns TTTTRRRRUUUUEEEE.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 4444
-
-
-
-